﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AFCEPF.Samples.WebSamples.Controls
{
    public partial class View_ComboBox_Dictionary : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList1.DataSource = BindingProvider.GetListOfKeyedStrings();
                DropDownList1.DataTextField = "Value";
                DropDownList1.DataValueField = "Key";
                DropDownList1.DataBind();
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string msg = string.Format("You chose {0} with value {1}",
                                       DropDownList1.SelectedItem.Text,
                                       DropDownList1.SelectedItem.Value);

            Label1.Text = msg;
        }
    }
}